<?php
Class Parse_101{

	private $xml;
	private $res;

	function Parse_101(){
		$this->res	= array();
	}

	function Parse($xml){
		$doc 			= new DOMDocument();
		$doc->loadXML($xml);
		$res			= array();
		$res['ResultCode']	= $doc->getElementsByTagName( "ResultCode" )->item(0)->nodeValue;
		$res['ResultDesc']	= $doc->getElementsByTagName( "ResultDesc" )->item(0)->nodeValue;
		$res['HLRSN']		= $doc->getElementsByTagName( "HLRSN" )->item(0)->nodeValue;
		$res['IMSI']		= $doc->getElementsByTagName( "IMSI" )->item(0)->nodeValue;
		$res['ISDN']		= $doc->getElementsByTagName( "ISDN" )->item(0)->nodeValue;
		$res['CardType']	= $doc->getElementsByTagName( "CardType" )->item(0)->nodeValue;
		$res['NAM']		= $doc->getElementsByTagName( "NAM" )->item(0)->nodeValue;
		$res['CATEGORY']	= $doc->getElementsByTagName( "CATEGORY" )->item(0)->nodeValue;
		$i			= 0;
		foreach($doc->getElementsByTagName( "TS" ) AS $ts){
			$res['BASIC_SERVICE']['TS'][$i]		= $ts->nodeValue;
			$i++;
		}
		$i			= 0;
		foreach($doc->getElementsByTagName( "BS" ) AS $bs){
			$res['BASIC_SERVICE']['BS'][$i]		= $bs->nodeValue;
			$i++;
		}
		$res['DEFAULTCALL_TS']	= $doc->getElementsByTagName( "DEFAULTCALL_TS" )->item(0)->nodeValue;
		$res['ODBENTE']		= $doc->getElementsByTagName( "ODBENTE" )->item(0)->nodeValue;
		$res['CFU']		= $doc->getElementsByTagName( "CFU" )->item(0)->nodeValue;
		$res['CFB']		= $doc->getElementsByTagName( "CFB" )->item(0)->nodeValue;
		$res['CFNRY']		= $doc->getElementsByTagName( "CFNRY" )->item(0)->nodeValue;
		$res['CFNRC']		= $doc->getElementsByTagName( "CFNRC" )->item(0)->nodeValue;
		$res['BAOC']		= $doc->getElementsByTagName( "BAOC" )->item(0)->nodeValue;
		$res['BOIC']		= $doc->getElementsByTagName( "BOIC" )->item(0)->nodeValue;
		$res['BOICEXHC']	= $doc->getElementsByTagName( "BOICEXHC" )->item(0)->nodeValue;
		$res['BAIC']		= $doc->getElementsByTagName( "BAIC" )->item(0)->nodeValue;
		$res['BICROAM']		= $doc->getElementsByTagName( "BICROAM" )->item(0)->nodeValue;
		$res['CLIP']		= $doc->getElementsByTagName( "CLIP" )->item(0)->nodeValue;
		$res['CW']		= $doc->getElementsByTagName( "CW" )->item(0)->nodeValue;
		$res['HOLD']		= $doc->getElementsByTagName( "HOLD" )->item(0)->nodeValue;
		$res['MPTY']		= $doc->getElementsByTagName( "MPTY" )->item(0)->nodeValue;
		$i			= 0;
		foreach($doc->getElementsByTagName( "CNTXID" ) AS $CNTXID){
			$res['GPRS_DATA']['CNTXID'][$i]		= $CNTXID->nodeValue;
			$i++;
		}
		$i			= 0;
		foreach($doc->getElementsByTagName( "APNTPLID" ) AS $APNTPLID){
			$res['GPRS_DATA']['APNTPLID'][$i]	= $APNTPLID->nodeValue;
			$i++;
		}
		$res['SMDP']		= $doc->getElementsByTagName( "SMDP" )->item(0)->nodeValue;
		$res['RROption']	= $doc->getElementsByTagName( "RROption" )->item(0)->nodeValue;
		$this->res		= $res;
	}
	
	function Response(){
		return $this->res;
	}

}
$file	= "PERFIL_101.txt";
$xml	= file_get_contents($file);
$p101	= new Parse_101();
$p101->Parse($xml);
$res	= $p101->Response();
var_dump($res);
?>
